<?php
    class Dispatcher
    {
        public function dispatch(Request $request)
        {
            //获取控制器/方法格式 http 请求数据
            $action = substr($request->path,1);
            $action = explode('/', $action);
            $action[0] = ucfirst($action[0]).'Controller';
            @$action[1] or $action[1] = 'index';
            if(strpos($action[0],'.')){
                return ;
            }
            //实例化控制器
            if(class_exists($action[0])){
                $controller = new $action[0]($request);
            }else{
                return;
            }
            if(method_exists($controller,$action[1])){
                call_user_func(array($controller, $action[1]));
                return $controller->request;
            }else{
                return;
            }
        }
    }